<?php
/**
 * (exporter)
 */
namespace App\Exporter\Reimburse;

use App\Models\Basics\SysCountry;
use App\Models\Reimburse\ReimburseApply;
use App\Models\Reimburse\ReimbursePaid;
use App\Util\User;
use Encore\Admin\Grid\Exporters\ExcelExporter;
use Maatwebsite\Excel\Concerns\WithMapping;
class PaidExporter extends ExcelExporter implements WithMapping
{
    protected $fileName = '返款支付.csv';

    protected $headings =  ['提报时间','付款状态','提报单号','类型','订单号/费用描述','国家','销售员','亚马逊SKU',
        'SKU','SKU名称','品类','支付方式','支付账号','币种','支付金额(原币)','付款时间','备注'];

    public function map($model) : array
    {
        return [
            $model->created_at,
            ReimburseApply::$_paidStatus[$model->paid_status],
            $model->reimburse_no,
            ReimbursePaid::$_orderBy[$model->order_by],
            $model->apply->order_no ?? '',
            SysCountry::getCountryById($model->apply->country_id ?? ''),
            User::getUsernameById($model->apply->seller_id ?? ''),
            $model->apply->seller_sku ?: '',
            $model->apply->sku->psku_code ?? '',
            $model->apply->sku->psku_cn ?? '',
            $model->apply->skuClassify->title ?? '',
            ReimburseApply::$_paidMethod[$model->paid_method],
            $model->paid_account_no,
            $model->currency_code,
            $model->paid_amount,
            $model->paid_date,
            $model->apply->remarks ?? '',
        ];
    }
}
